var e = require;
var t = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("NotifyEventType"),
    a = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("AudioManager"),
    s = e("ModuleUI"),
    l = e("CommonHelper"),
    c = e("nameCfg"),
    d = e("AD"),
    h = cc._decorator,
    _ = h.ccclass,
    u = h.property,
    p = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.player_head_sprite = null),
                (t.player_name_label = null),
                (t.player_level_sprite = null),
                (t.star_node = null),
                (t.head_list_view = null),
                (t.head_num_label = null),
                (t.list_num = 0),
                t
            );
        }
        return (
            __extends(t, e),

            (t.prototype.onDisable = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();

            }),
            

            (t.prototype.initView = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();
                Adv_skd.default.instance.showGridAdLeft();
                Adv_skd.default.instance.showGridAdRight();
                Adv_skd.default.instance.showGridAdTop();
                Adv_skd.default.instance.showInterstitialAd();

                e.prototype.initView.call(this), (this.list_num = 0), this.showPlayerInfo(), this.showHeadList();
            }),
            (t.prototype.OnClick = function (t) {
                var o = this;
                e.prototype.OnClick.call(this, t);
                var i = t.node,
                    s = i.name,
                    h = a.GlobalParams.PlayerInfo.value;
                switch (s) {
                    case "back_btn":
                        this.emitEvent(n.default.SEND_BOX_PORTAL_INFO, !0), this.node.destroy();
                        break;
                    case "update_name":
                        d.default.getInstance().showVideo(function (e) {
                            r.default.playGameBGM(),
                                e == d.ResultEnum.Success &&
                                    ((h.name =
                                        c.default.nameList[l.default.getRandomInt(0, c.default.nameList.length - 1)]),
                                    (a.GlobalParams.PlayerInfo.value = h),
                                    o.emitEvent(n.default.SEND_UPDATE_PLAYER_INFO),
                                    o.showPlayerInfo());
                        });
                        break;
                    case "up_btn":
                        this.list_num--, (this.list_num = this.list_num < 0 ? 3 : this.list_num), this.showHeadList();
                        break;
                    case "next_btn":
                        this.list_num++, (this.list_num = this.list_num > 3 ? 0 : this.list_num), this.showHeadList();
                        break;
                    case "head_1":
                    case "head_2":
                    case "head_3":
                    case "head_4":
                    case "head_5":
                        var _ = Number(l.default.getNameType(s, "head_")),
                            u = 5 * this.list_num + _,
                            p = function () {
                                (h.head = u),
                                    (a.GlobalParams.PlayerInfo.value = h),
                                    o.emitEvent(n.default.SEND_UPDATE_PLAYER_INFO),
                                    o.showPlayerInfo();
                            };
                        i.children[2].active
                            ? d.default.getInstance().showVideo(function (e) {
                                  r.default.playGameBGM(),
                                      e == d.ResultEnum.Success &&
                                          ((i.children[2].active = !1), h.have_head.push(u), p());
                              })
                            : p();
                }
            }),
            (t.prototype.showPlayerInfo = function () {
                var e = a.GlobalParams.PlayerInfo.value;
                (this.player_head_sprite.spriteFrame = i.default.getInstance().getPlayerHeadFrame(e.head)),
                    (this.player_name_label.string = "" + e.name),
                    (this.player_level_sprite.spriteFrame = i.default
                        .getInstance()
                        .getPlayerLevelExp(e.level > 28 ? 28 : e.level));
                for (var t = 0; t < 4; t++) this.star_node.children[t].children[0].active = t <= e.exp;
            }),
            (t.prototype.showHeadList = function () {
                for (var e = a.GlobalParams.PlayerInfo.value, t = 1; t < 6; t++) {
                    var o = this.head_list_view.children[t - 1],
                        n = 5 * this.list_num + t;
                    (o.active = n < 20),
                        (o.children[0].active = n == e.head),
                        (o.children[1].getComponent(cc.Sprite).spriteFrame = i.default
                            .getInstance()
                            .getPlayerHeadFrame(n)),
                        (o.children[2].active = -1 == e.have_head.indexOf(n));
                }
                this.head_num_label.string = this.list_num + 1 + " / 4";
            }),
            __decorate([u(cc.Sprite)], t.prototype, "player_head_sprite", void 0),
            __decorate([u(cc.Label)], t.prototype, "player_name_label", void 0),
            __decorate([u(cc.Sprite)], t.prototype, "player_level_sprite", void 0),
            __decorate([u(cc.Node)], t.prototype, "star_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "head_list_view", void 0),
            __decorate([u(cc.Label)], t.prototype, "head_num_label", void 0),
            __decorate([_], t)
        );
    })(s.default);
o.default = p;
